<?php
namespace Home\Model;
use \Frame\Libs\BaseModel;

final class SafeModel extends BaseModel{
	//向数据库插入验证码
	public function insertCode($acc,$code){
		$sql = "UPDATE love_user SET code='$code',code_time=now() WHERE account='$acc'";
		return $this->pdo->exec($sql);
	}
	//读出验证码
	public function getCode($acc){
		$sql = "SELECT code,code_time FROM love_user WHERE account='$acc'";
		return $this->pdo->fetchOne($sql);
	}
	//清空验证码
	public function delCode($acc){
	    $sql = "UPDATE love_user SET code=null,code_time=null WHERE account='$acc'";
		return $this->pdo->exec($sql);
	}
}
?>